package com.reliable.service.enums;

/**
 * 用户类型枚举
 */
public enum UserType {
    ADMIN(1, "管理员"),
    USER(2, "用户");

    private final int value;
    private final String description;

    UserType(int value, String description) {
        this.value = value;
        this.description = description;
    }

    public int getValue() {
        return value;
    }

    public String getDescription() {
        return description;
    }

    /**
     * 根据值获取对应的枚举
     * @param value 枚举值
     * @return UserType
     */
    public static UserType fromValue(int value) {
        for (UserType type : values()) {
            if (type.value == value) {
                return type;
            }
        }
        throw new IllegalArgumentException("Invalid value for UserType: " + value);
    }
}
